/*
 * VHMain.java
 * Created on 25 mai 2009
 *
 * VirtualHockey Internet Platform
 * http://code.google.com/p/virtualhockey/
 *
 * Copyright (c) 2005-2009, Jens and Jan Janke (VirtualHockey Project)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 */

package com.hockeo.vhweb.client;

import com.extjs.gxt.ui.client.util.IconHelper;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.AbstractImagePrototype;
import com.hockeo.vhweb.client.mvc.VHDispatcher;
import com.hockeo.vhweb.client.mvc.VHEvent;
import com.hockeo.vhweb.client.res.VHResConstants;
import com.hockeo.vhweb.client.res.VHResLookupConstants;
import com.hockeo.vhweb.client.res.VHResMessages;
import com.hockeo.vhweb.client.res.VHWeb;

/**
 * Main class of the VirtualHockey GUI.
 *
 * @version $Id$
 * @author jjanke
 */
public class VHMain implements EntryPoint
{
  public static final AbstractImagePrototype ICON_NEWS_AND_STATS    = IconHelper.createPath(
                                                                        "images/nav/countrystats.png", 16, 16 );
  public static final AbstractImagePrototype ICON_CLUB              = IconHelper.createPath( "images/nav/club.png", 16,
                                                                        16 );
  public static final AbstractImagePrototype ICON_LEAGUE            = IconHelper.createPath( "images/nav/league.png",
                                                                        16, 16 );
  public static final AbstractImagePrototype ICON_NATIONAL_CUP      = IconHelper.createPath(
                                                                        "images/nav/nationalcup.png", 16, 16 );
  public static final AbstractImagePrototype ICON_STANDINGS         = IconHelper.createPath(
                                                                        "images/nav/standings.png", 16, 16 );
  public static final AbstractImagePrototype ICON_STATS             = IconHelper.createPath( "images/nav/stats.png",
                                                                        16, 16 );
  public static final AbstractImagePrototype ICON_MATCH_LIST        = IconHelper.createPath(
                                                                        "images/nav/matchlist.png", 16, 16 );
  public static final AbstractImagePrototype ICON_CLUB_LIST         = IconHelper.createPath( "images/nav/clublist.png",
                                                                        16, 16 );
  public static final AbstractImagePrototype ICON_WINNER_LIST       = IconHelper.createPath(
                                                                        "images/nav/winnerlist.png", 16, 16 );
  public static final AbstractImagePrototype ICON_ETERNAL_STANDINGS = IconHelper.createPath(
                                                                        "images/nav/eternalstandings.png", 16, 16 );
  public static final AbstractImagePrototype ICON_HISTORY           = IconHelper.createPath( "images/nav/history.png",
                                                                        16, 16 );
  public static final AbstractImagePrototype ICON_TROPHY            = IconHelper.createPath( "images/nav/trophy.png",
                                                                        16, 16 );

  private static VHWeb                       d_resAppConstants;
  private static VHResConstants              d_resConstants;
  private static VHResLookupConstants        d_resLookupConstants;
  private static VHResMessages               d_resMessages;

  /**
   * This is the entry point method.
   */
  public void onModuleLoad()
  {
    VHDispatcher dispatcher = VHDispatcher.get();

    dispatcher.addController( new VHMainController() );
    dispatcher.dispatch( new VHEvent( VHEvent.EventType.APP_INIT ) );
  }

  public static VHWeb getAppConstants()
  {
    if ( d_resAppConstants == null )
      d_resAppConstants = GWT.create( VHWeb.class );

    return d_resAppConstants;
  }

  public static VHResConstants getConstants()
  {
    if ( d_resConstants == null )
      d_resConstants = GWT.create( VHResConstants.class );

    return d_resConstants;
  }

  public static VHResLookupConstants getLookupConstants()
  {
    if ( d_resLookupConstants == null )
      d_resLookupConstants = GWT.create( VHResLookupConstants.class );

    return d_resLookupConstants;
  }

  public static VHResMessages getMessages()
  {
    if ( d_resMessages == null )
      d_resMessages = GWT.create( VHResMessages.class );

    return d_resMessages;
  }
}
